<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    {include file="common/head_static" /}
</head>
<style>
    .cls{
        font-size: 30px;
        margin-top: -20px;
        margin-left: -10px;
    }
    .cls:hover{
        cursor:pointer;
    }
</style>
<body>

    <div class="layui-row">
        <div class="layui-col-md12" style="margin-top: 10px;padding: 10px;">
            <h3 class="header-dividing">渠道设置</h3>
            {volist name="list" id="vo"}

            <div style="width: 150px; float: left">
                <button class="layui-btn layui-btn-lg layui-btn-normal"><i class="layui-icon layui-icon-note" ></i>{$vo.name}</button>
                <i class="layui-icon layui-icon-close-fill cls" onclick="deletes({$vo.id})"></i>
            </div>
            {/volist}

            <div class="input-group" style="width: 300px;margin-top: 10px;float: left">
                <span class="input-group-addon">渠道</span>
                <input type="text" class="form-control" id="name" placeholder="+添加新渠道">
                <span class="input-group-addon">
                    <i class="layui-icon layui-icon-add-circle-fine" style="cursor:pointer;" onclick="add()"></i></i>
                </span>
            </div>
        </div>
    </div>

</body>
<script>
    function add(){
        if($('#name').val() == ''){
            alert('不能为空');
            return false;
        }
        $.ajax({
            type:"post",
            url: "{:url('admin/system/channel')}",
            data: {
                name:$('#name').val()
            },
            //回调函数
            success: function(data){
//                console.log(data);
                if(data.code == 100){
                    alert(data.msg);
                    window.location.reload();
                }else{
                    alert(data.msg);
                }
            }});
    }


    function deletes(id){
        $.ajax({
            type:"post",
            url: "{:url('admin/system/remove')}",
            data: {
                id:id
            },
            //回调函数
            success: function(data){
//                console.log(data);
                if(data.code == 100){
                    alert(data.msg);
                    window.location.reload();
                }else{
                    alert(data.msg);
                }
            }});
    }
</script>
</html>